(define (over-or-under num1 num2)
  'YOUR-CODE-HERE
  (cond 
    ((> num1 num2) 1)
    ((= num1 num2) 0)
    ((< num1 num2) -1))
)

;;; Tests
(over-or-under 1 2)
; expect -1
(over-or-under 2 1)
; expect 1
(over-or-under 1 1)
; expect 0


(define (filter-lst fn lst)
  (if (null? lst) 
    nil
    (if (fn (car lst)) (cons (car lst) (filter-lst fn (cdr lst))) (filter-lst fn (cdr lst))))
)

;;; Tests
(define (even? x)
  (= (modulo x 2) 0))
(filter-lst even? '(0 1 1 2 3 5 8))
; expect (0 2 8)


(define (make-adder num)
  'YOUR-CODE-HERE
  (lambda (x) (+ num x))
)

;;; Tests
(define adder (make-adder 5))
(adder 8)
; expect 13


(define lst
  (list (cons 1 nil) 2 (cons 3 (cons 4 nil)) 5)
)


(define (composed f g)
  (lambda (x) (f (g x)))
)


(define (remove item lst)
  (if (null? lst)
    nil
    (filter (lambda (l) (not (= item l))) lst)
  )
)


;;; Tests
(remove 3 nil)
; expect ()
(remove 3 '(1 3 5))
; expect (1 5)
(remove 5 '(5 3 5 5 1 4 5 4))
; expect (3 1 4 4)


(define (no-repeats s)
  (if (null? s)
    nil
    (if (null? (cdr s)) 
      (list (car s))
      (append (list (car s)) (no-repeats (filter (lambda (l) (not (= (car s) l))) (cdr s))))
    )
  )
)


(define (substitute s old new)
  (if (pair? (car s))
    (if (null? (cdr s))
      (list (substitute (car s) old new))
      (append (list (substitute (car s) old new)) (substitute (cdr s) old new ))
    )
    (if (null? (cdr s))
      (if (equal? old (car s))
        (list new)
        (list (car s))
      )
      (if (equal? old (car s))
        (append (list new) (substitute (cdr s) old new) )
        (append (list (car s)) (substitute (cdr s) old new) )
      )
    )
  )
)


(define (sub-all s olds news)
  (if (null? (car olds))
    nil
    (if (null? (cdr olds))
      (substitute s (car olds) (car news))
      (sub-all (substitute s (car olds) (car news)) (cdr olds) (cdr news))
    )
  )
  
)

